import requests
import retrying

error_url = 'https://github.com/'

headers = {
    'User-Agent':'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/129.0.0.0 Safari/537.36',

}

# 允许重试5次
@retrying.retry(stop_max_attempt_number=5)
def get_html(url):
    resp = requests.get(url,headers=headers,timeout=3)
    assert resp.status_code == 200,'状态码错误'
    return resp



def main():
    try:
        resp = get_html(error_url)
        print(resp.text)
    except Exception as e:
        print(e)



if __name__ == '__main__':
    main()